<template>
  <div></div>
</template>
<script lang="ts" setup>
import { usePermissionStore } from '@/store/modules/permission'

defineOptions({ name: 'Home' })

// 跳转到第一个可用路由页
const router = useRouter() // 路由对象
const permissionStore = usePermissionStore()

const firstRouter = permissionStore.addRouters[0] as AppRouteRecordRaw
let path = '/404'
if (firstRouter) {
  path = firstRouter.path
  if (firstRouter.children && firstRouter.children.length > 0) {
    path += '/' + firstRouter.children[0].path
  }
}
if (!path.startsWith('/')) {
  path = '/' + path
}
if (path.endsWith('/')) {
  path = path.substring(0, path.length - 1)
}
path = path.replace('//', '/')
router.replace(path)
</script>
